package com.ruoyi.web.wuliu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.wuliu.domain.TSpecialLine;
import com.ruoyi.web.wuliu.service.ITSpecialLineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专线Controller
 * 
 * @author ruoyi
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/wuliu/line")
public class TSpecialLineController extends BaseController
{
    @Autowired
    private ITSpecialLineService tSpecialLineService;

    /**
     * 查询专线列表
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:list')")
    @GetMapping("/list")
    public TableDataInfo list(TSpecialLine tSpecialLine)
    {
        startPage();
        List<TSpecialLine> list = tSpecialLineService.selectTSpecialLineList(tSpecialLine);
        return getDataTable(list);
    }

    /**
     * 导出专线列表
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:export')")
    @Log(title = "专线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TSpecialLine tSpecialLine)
    {
        List<TSpecialLine> list = tSpecialLineService.selectTSpecialLineList(tSpecialLine);
        ExcelUtil<TSpecialLine> util = new ExcelUtil<TSpecialLine>(TSpecialLine.class);
        util.exportExcel(response, list, "专线数据");
    }

    /**
     * 获取专线详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(tSpecialLineService.selectTSpecialLineById(id));
    }

    /**
     * 新增专线
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:add')")
    @Log(title = "专线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TSpecialLine tSpecialLine)
    {
        return toAjax(tSpecialLineService.insertTSpecialLine(tSpecialLine));
    }

    /**
     * 修改专线
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:edit')")
    @Log(title = "专线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TSpecialLine tSpecialLine)
    {
        return toAjax(tSpecialLineService.updateTSpecialLine(tSpecialLine));
    }

    /**
     * 删除专线
     */
    @PreAuthorize("@ss.hasPermi('wuliu:line:remove')")
    @Log(title = "专线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(tSpecialLineService.deleteTSpecialLineByIds(ids));
    }
}
